package com.objecttopersonsystem.controller;

import com.objecttopersonsystem.pojo.Record;
import com.objecttopersonsystem.pojo.Result;
import com.objecttopersonsystem.service.RecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class RecordController {

    @Autowired
    private RecordService recordService;

    @GetMapping("/manage")
    public Result list(){
        log.info("查询全部物找人数据");
        List<Record> recordList = recordService.list();
        return Result.success(recordList);
    }

    @DeleteMapping("/manage/{id}")
    public Result delete(@PathVariable Integer id){
        log.info("根据id删除对应的物找人记录:{}",id);
        recordService.delete(id);
        return Result.success();
    }
}
